import { VxeGridPropTypes } from '@/components/VxeTable';
import { Tag } from 'ant-design-vue';
import { h } from 'vue';

export default [
  {
    title: '资源名称',
    field: 'name',
    treeNode: true
  },
  {
    title: '资源值',
    field: 'value'
  },
  {
    title: '编码',
    field: 'code'
  },
  {
    title: '状态',
    field: 'status',
    slots: {
      default({ row }) {
        const status = row.status;
        const enable = ~~status === 1;
        const color = enable ? 'green' : 'red';
        const text = enable ? '启用' : '停用';
        return h(Tag, { color: color }, () => text);
      }
    }
  },

  {
    title: '排序',
    field: 'order'
  },
  {
    title: '备注',
    field: 'remark'
  },
  {
    title: '创建时间',
    field: 'createTime',
    visible: false
  },
  {
    width: 140,
    title: '操作',
    align: 'center',
    slots: { default: 'action' },
    fixed: 'right'
  }
] as VxeGridPropTypes.Columns;
